package com.newviews.tcmip.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.newviews.tcmip.common.constant.CommonConsts;
import com.newviews.tcmip.common.enums.UiElCodeEnums;
import com.newviews.tcmip.common.model.PageModel;
import com.newviews.tcmip.common.model.ResultModel;
import com.newviews.tcmip.dao.EtcmHerbExMapper;
import com.newviews.tcmip.dao.EtcmPxExMapper;
import com.newviews.tcmip.pojo.po.*;
import com.newviews.tcmip.dao.EtcmHerbMapper;
import com.newviews.tcmip.pojo.vo.EtcmCommonBaseInfoRespVO;
import com.newviews.tcmip.pojo.vo.export.EtcmDiseaseExportReqVO;
import com.newviews.tcmip.pojo.vo.index.EtcmIndexStatusticsRespVO;
import com.newviews.tcmip.service.inf.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.newviews.tcmip.web.vo.combin.NetworkStatisticsRespVo;
import com.newviews.tcmip.web.vo.etcmherb.HerbIngrVo;
import com.newviews.tcmip.web.vo.etcmherb.download.EtcmHerbExportReqVO;
import com.newviews.tcmip.web.vo.etcmherb.statistics.HerbStatisticsRespVo;
import com.newviews.tcmip.web.vo.etcmpx.PxIngrStatisticsRespVo;
import com.newviews.tcmip.web.vo.etcmpx.PxNetworkStatisticsRespVo;
import com.newviews.tcmip.web.vo.etcmpx.network.Relations;
import com.newviews.tcmip.web.vo.etcmpx.network.RelationsName;
import com.newviews.tcmip.web.vo.etcmpx.network.ResolutionNames;
import com.newviews.tcmip.web.vo.etcmpx.network.ScatterDiagram;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>
 * 中草药库 服务实现类
 * </p>
 *
 * @author lxc
 * @since 2024-02-29
 */
@Service
public class EtcmHerbServiceImpl extends ServiceImpl<EtcmHerbMapper, EtcmHerbPo> implements EtcmHerbServiceInf {

    @Resource
    private EtcmHerbFlavorServiceInf etcmHerbFlavorServiceInf;
    @Resource
    private EtcmHerbPropertyServiceInf etcmHerbPropertyServiceInf;

    @Resource
    private EtcmHerbExServiceInf etcmHerbExServiceInf;

    @Resource
    private EtcmIngrExServiceInf etcmIngrExServiceInf;
    @Resource
    private EtcmPxExServiceInf etcmPxExServiceInf;
    @Resource
    private EtcmPxServiceInf etcmPxServiceInf;
    @Resource
    private EtcmDiseaseExServiceInf etcmDiseaseExServiceInf;
    @Resource
    private EtcmHerbExMapper etcmHerbExMapper;

    @Resource
    private EtcmExperimentalRecordsExServiceInf etcmExperimentalRecordsExServiceInf;
    @Resource
    private EtcmPxExMapper etcmPxExMapper;
    @Resource
    private EtcmTargetExServiceInf etcmTargetExService;

    @Override
    public ResultModel<EtcmIndexStatusticsRespVO> getStatisticsHerb(String langCode, String uiTypeCode, String meridians, String flavor, String property, String prepositionContent) {
        QueryWrapper<EtcmHerbExPo> wrapper = new QueryWrapper<>();
        EtcmIndexStatusticsRespVO vo = new EtcmIndexStatusticsRespVO();
        vo.setHerbs(0);
        if (StringUtils.isBlank(flavor) && StringUtils.isBlank(property) && StringUtils.isBlank(meridians)){
            return new ResultModel<EtcmIndexStatusticsRespVO>().success(vo);
        }

        if (StringUtils.isNotBlank(flavor)){
            wrapper.in("t2.flavor_code",flavor.split(","));
        }

        if (StringUtils.isNotBlank(property)){
            wrapper.in("t3.property_code",property.split(","));
        }

        if (StringUtils.isNotBlank(meridians)){
            wrapper.in("t4.meridians_code",meridians.split(","));
        }

        if (StringUtils.isNotBlank(prepositionContent)){
            wrapper.and(w->w.like( "t1.herb_zh_name", prepositionContent)
                    .or().like( "t1.herb_zh_name_py", prepositionContent)
                    .or().like( "t1.herb_zh_name_wb", prepositionContent)
                    .or().like( "t1.herb_zh_name_abb", prepositionContent)
                    .or().like( "t1.herb_en_name", prepositionContent)
                    .or().like( "t1.herb_en_name_abb", prepositionContent)
                    .or().like( "t1.herb_latin_name", prepositionContent)
                    .or().like( "t1.herb_latin_name_abb", prepositionContent)
                    .or().like( "t1.herb_name_alias", prepositionContent)
            );
        }
        wrapper.eq("t1.status",CommonConsts.COMMON_YES);
        wrapper.groupBy("t1.id");
        List<EtcmHerbExPo> page = etcmHerbExMapper.getStatisticsHerb( wrapper);
        vo.setHerbs(page.size());
        return new ResultModel<EtcmIndexStatusticsRespVO>().success(vo);
    }

    @Override
    public ResultModel<PageModel<Map<String,String>>> getIndexPage(String languageCode ,String uiTypeCode, Integer pageNo, Integer pageSize,String searchName, String meridians, String herbFlavorCode, String herbPropertyCode ,String sortType,String pContent) {
        QueryWrapper<EtcmHerbPo> wrapper = new QueryWrapper<>();

        if (StringUtils.isBlank(herbFlavorCode) && StringUtils.isBlank(herbPropertyCode) && StringUtils.isBlank(meridians)){
            return new ResultModel<PageModel<Map<String,String>>>().success(new PageModel<>());
        }

        if (StringUtils.isNotBlank(herbFlavorCode)){
            wrapper.in("t2.flavor_code",herbFlavorCode.split(","));
        }

        if (StringUtils.isNotBlank(herbPropertyCode)){
            wrapper.in("t3.property_code",herbPropertyCode.split(","));
        }

        if (StringUtils.isNotBlank(meridians)){
            wrapper.in("t4.meridians_code",meridians.split(","));
        }
        if (StringUtils.isNotBlank(searchName)){
            wrapper.and(w->w.like( "t1.herb_zh_name", searchName)
                    .or().like( "t1.herb_zh_name_py", searchName)
                    .or().like( "t1.herb_zh_name_wb", searchName)
                    .or().like( "t1.herb_zh_name_abb", searchName)
                    .or().like( "t1.herb_en_name", searchName)
                    .or().like( "t1.herb_en_name_abb", searchName)
                    .or().like( "t1.herb_latin_name", searchName)
                    .or().like( "t1.herb_latin_name_abb", searchName)
                    .or().like( "t1.herb_name_alias", searchName)
            );
        }
        if (StringUtils.isNotBlank(pContent)){
            wrapper.and(w->w.like( "t1.herb_zh_name", pContent)
                    .or().like( "t1.herb_zh_name_py", pContent)
                    .or().like( "t1.herb_zh_name_wb", pContent)
                    .or().like( "t1.herb_zh_name_abb", pContent)
                    .or().like( "t1.herb_en_name", pContent)
                    .or().like( "t1.herb_en_name_abb", pContent)
                    .or().like( "t1.herb_latin_name", pContent)
                    .or().like( "t1.herb_latin_name_abb", pContent)
                    .or().like( "t1.herb_name_alias", pContent)
            );
        }
        wrapper.eq("t1.status", CommonConsts.COMMON_YES);
        if(StringUtils.isNotBlank(sortType)){
            if(sortType.toLowerCase().equals(CommonConsts.SORT_TYPE_ASC.toLowerCase())){
                wrapper.orderByAsc("t1.herb_code");
            }else {
                wrapper.orderByDesc("t1.herb_code");
            }
        }else{
            wrapper.orderByAsc("t1.herb_code");
        }

        wrapper.groupBy("t1.id");
        IPage<EtcmHerbPo> page = etcmHerbExMapper.getIndexPage(new Page<>(pageNo,pageSize), wrapper);

        List<EtcmHerbExPo> selectList = etcmHerbExMapper.selectList(new QueryWrapper<EtcmHerbExPo>().eq("language_code", languageCode).eq("ui_type_code", uiTypeCode).eq("status", CommonConsts.COMMON_YES));


        List<Map<String,String>> resList = new ArrayList<>();

        for (EtcmHerbPo record : page.getRecords()) {
            HashMap<String,String> map = new HashMap<>(16);
            for (EtcmHerbExPo etcmHerbExPo : selectList) {
                if (record.getHerbCode().equals(etcmHerbExPo.getHerbId())){
                    map.put(etcmHerbExPo.getUiElCode(),etcmHerbExPo.getHerbExCon());
                }
            }
            resList.add(map);
        }



        PageModel<Map<String,String>> resPage = new PageModel<>();
        resPage.setPageNo(pageNo);
        resPage.setPageSize(pageSize);
        resPage.setRecords(resList);
        resPage.setTotalCount(page.getTotal());
        return new ResultModel<PageModel<Map<String,String>>>().success(resPage);
    }

    @Override
    public List<Map<String, String>> getHerbDownload(EtcmHerbExportReqVO reqVO) {
        QueryWrapper<EtcmHerbPo> wrapper = new QueryWrapper<>();

        if (StringUtils.isBlank(reqVO.getFlavor()) && StringUtils.isBlank(reqVO.getProperty()) && StringUtils.isBlank(reqVO.getMeridians())){
            return new ArrayList<>();
        }

        if (StringUtils.isNotBlank(reqVO.getFlavor())){
            wrapper.in("t2.flavor_code",reqVO.getFlavor().split(","));
        }

        if (StringUtils.isNotBlank(reqVO.getProperty())){
            wrapper.in("t3.property_code",reqVO.getProperty().split(","));
        }

        if (StringUtils.isNotBlank(reqVO.getMeridians())){
            wrapper.in("t4.meridians_code",reqVO.getMeridians().split(","));
        }
        if (StringUtils.isNotBlank(reqVO.getContent())){
            wrapper.and(w->w.like( "t1.herb_zh_name", reqVO.getContent())
                    .or().like( "t1.herb_zh_name_py", reqVO.getContent())
                    .or().like( "t1.herb_zh_name_wb", reqVO.getContent())
                    .or().like( "t1.herb_zh_name_abb", reqVO.getContent())
                    .or().like( "t1.herb_en_name", reqVO.getContent())
                    .or().like( "t1.herb_en_name_abb", reqVO.getContent())
                    .or().like( "t1.herb_latin_name", reqVO.getContent())
                    .or().like( "t1.herb_latin_name_abb", reqVO.getContent())
                    .or().like( "t1.herb_name_alias", reqVO.getContent())
            );
        }
        if (StringUtils.isNotBlank(reqVO.getPrepositionContent())){
            wrapper.and(w->w.like( "t1.herb_zh_name", reqVO.getPrepositionContent())
                    .or().like( "t1.herb_zh_name_py", reqVO.getPrepositionContent())
                    .or().like( "t1.herb_zh_name_wb", reqVO.getPrepositionContent())
                    .or().like( "t1.herb_zh_name_abb", reqVO.getPrepositionContent())
                    .or().like( "t1.herb_en_name", reqVO.getPrepositionContent())
                    .or().like( "t1.herb_en_name_abb", reqVO.getPrepositionContent())
                    .or().like( "t1.herb_latin_name", reqVO.getPrepositionContent())
                    .or().like( "t1.herb_latin_name_abb", reqVO.getPrepositionContent())
                    .or().like( "t1.herb_name_alias", reqVO.getPrepositionContent())
            );
        }
        wrapper.eq("t1.status", CommonConsts.COMMON_YES);
        if(reqVO.getSortType().equals(CommonConsts.SORT_TYPE_ASC)){
            wrapper.orderByAsc("t1.id");
        }else {
            wrapper.orderByDesc("t1.id");
        }
        wrapper.groupBy("t1.id");
        List<EtcmHerbPo> page = etcmHerbExMapper.getIndexDownload(wrapper);

        List<EtcmHerbExPo> selectList = etcmHerbExMapper.selectList(new QueryWrapper<EtcmHerbExPo>().eq("language_code", reqVO.getLangCode()).eq("ui_type_code", reqVO.getUiTypeCode()).eq("status", CommonConsts.COMMON_YES));

        Map<String,List<EtcmHerbExPo>> disMap = new HashMap<>(16);
        for (EtcmHerbPo record : page) {
            List<EtcmHerbExPo> disList = new ArrayList<>();
            for (EtcmHerbExPo etcmHerbExPo : selectList) {
                if (etcmHerbExPo.getHerbId().equals(record.getHerbCode())) {
                    disList.add(etcmHerbExPo);
                }
            }

            disMap.put(record.getHerbCode(), disList);
        }
        List<EtcmUiElPo> etcmUiElPos = etcmPxExMapper.getUIElName(reqVO.getUiTypeCode(),reqVO.getLangCode());
        List<Map<String, String>> resultList = new ArrayList<>();

        for (String key : disMap.keySet()) {
            Map<String,String> mapRes=new HashMap<>(16);
            List<EtcmHerbExPo> values = disMap.get(key);
            List<String> collect = values.stream().map(EtcmHerbExPo::getUiElCode).collect(Collectors.toList());
            for (EtcmUiElPo etcmUiElPo : etcmUiElPos) {
                if (collect.contains(etcmUiElPo.getUiElCode())){
                    for (EtcmHerbExPo etcmHerbExPo : values) {
                        if (etcmUiElPo.getUiElCode().equals(etcmHerbExPo.getUiElCode())){
                            mapRes.put(etcmHerbExPo.getUiElCode(), etcmHerbExPo.getHerbExCon());
                        }
                    }
                }else {
                    mapRes.put(etcmUiElPo.getUiElCode(), "");
                }

            }

            resultList.add(mapRes);
        }

        if(reqVO.getSortType().toLowerCase().equals(CommonConsts.SORT_TYPE_ASC.toLowerCase())){
            Collections.sort(resultList, new Comparator<Map<String, String>>() {
                @Override
                public int compare(Map<String, String> o1, Map<String, String> o2) {
                    return String.valueOf(o1.get("100716826576556928")).compareTo(String.valueOf(o2.get("100716826576556928")));
                }
            });
        }else {
            Collections.sort(resultList, new Comparator<Map<String, String>>() {
                @Override
                public int compare(Map<String, String> o1, Map<String, String> o2) {
                    return -String.valueOf(o1.get("100716826576556928")).compareTo(String.valueOf(o2.get("100716826576556928")));
                }
            });
        }

        return resultList;
    }

    @Override
    public ResultModel<PageModel<Map<String,String>>> getPage(String languageCode ,String uiTypeCode, Integer pageNo, Integer pageSize,String searchName, String meridians, String herbFlavorCode, String herbPropertyCode ,String sortType ) {
        QueryWrapper<EtcmHerbExPo> wrapper = new QueryWrapper<>();

        if (StringUtils.isBlank(herbFlavorCode) && StringUtils.isBlank(herbPropertyCode) && StringUtils.isBlank(meridians)){
            return new ResultModel<PageModel<Map<String,String>>>().success(new PageModel<>());
        }

        if (StringUtils.isNotBlank(herbFlavorCode)){
            wrapper.in("t2.flavor_code",herbFlavorCode.split(","));
        }

        if (StringUtils.isNotBlank(herbPropertyCode)){
            wrapper.in("t3.property_code",herbPropertyCode.split(","));
        }

        if (StringUtils.isNotBlank(meridians)){
            wrapper.in("t4.meridians_code",meridians.split(","));
        }
        if (StringUtils.isNotBlank(searchName)){
            wrapper.and(w->w.like( "t1.herb_zh_name", searchName)
                    .or().like( "t1.herb_zh_name_py", searchName)
                    .or().like( "t1.herb_zh_name_wb", searchName)
                    .or().like( "t1.herb_zh_name_abb", searchName)
                    .or().like( "t1.herb_en_name", searchName)
                    .or().like( "t1.herb_en_name_abb", searchName)
                    .or().like( "t1.herb_latin_name", searchName)
                    .or().like( "t1.herb_latin_name_abb", searchName)
                    .or().like( "t1.herb_name_alias", searchName)
            );
        }

        wrapper.eq("t1.status", CommonConsts.COMMON_YES);
        if(sortType.toLowerCase().equals(CommonConsts.SORT_TYPE_ASC.toLowerCase())){
            wrapper.orderByAsc("s1.herb_id");
        }else {
            wrapper.orderByDesc("s1.herb_id");
        }
        wrapper.groupBy("s1.herb_id");
        IPage<EtcmHerbExPo> page = etcmHerbExMapper.getPage(new Page<>(pageNo,pageSize), wrapper,uiTypeCode, languageCode);


        List<Map<String,String>> resList = new ArrayList<>();

        for (EtcmHerbExPo record : page.getRecords()) {
            HashMap<String,String> map = new HashMap<>(16);
            String[] uiElCodeList = record.getUiElCode().split("\\|\\|");
            String[] herbExConList = record.getHerbExCon().split("\\|\\|");
            for (int i = 0; i < uiElCodeList.length; i++) {
                for (int j = 0; j < herbExConList.length; j++) {
                    if (i == j){
                        map.put(uiElCodeList[i],herbExConList[j]);
                    }
                }
            }

            resList.add(map);
        }



        PageModel<Map<String,String>> resPage = new PageModel<>();
        resPage.setPageNo(pageNo);
        resPage.setPageSize(pageSize);
        resPage.setRecords(resList);
        resPage.setTotalCount(page.getTotal());
        return new ResultModel<PageModel<Map<String,String>>>().success(resPage);
    }

    @Override
    public ResultModel<List<EtcmHerbMeridiansPo>> getMeridiansList(String langCode) {
        List<EtcmHerbMeridiansPo> clsList = etcmHerbExMapper.getMeridiansList(langCode);
        return new ResultModel<List<EtcmHerbMeridiansPo>>().success(clsList);
    }

    @Override
    public ResultModel<HerbStatisticsRespVo> getStatistics(String content) {
        QueryWrapper<EtcmHerbPo> wrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(content)){
            wrapper.and(w->w.like( "t1.herb_zh_name", content)
                    .or().like( "t1.herb_zh_name_py", content)
                    .or().like( "t1.herb_zh_name_wb", content)
                    .or().like( "t1.herb_zh_name_abb", content)
                    .or().like( "t1.herb_en_name", content)
                    .or().like( "t1.herb_en_name_abb", content)
                    .or().like( "t1.herb_latin_name", content)
                    .or().like( "t1.herb_latin_name_abb", content)
                    .or().like( "t1.herb_name_alias", content)
            );
        }
        List<String> flavorList = etcmHerbExMapper.getFlavorStatistics(wrapper);
        List<String> propertyList = etcmHerbExMapper.getPropertyStatistics(wrapper);
        List<String> meridiansList = etcmHerbExMapper.getMeridiansStatistics(wrapper);

        Map<String, Long> flavorMap = flavorList.stream().filter(StringUtils::isNotBlank).collect(Collectors.groupingBy(s -> s,Collectors.counting()));
        long flavorCount = flavorList.stream().filter(StringUtils::isNotBlank).count();
        Map<String, Long> propertyMap = propertyList.stream().filter(StringUtils::isNotBlank).collect(Collectors.groupingBy(s -> s,Collectors.counting()));
        long propertyCount = propertyList.stream().filter(StringUtils::isNotBlank).count();
        Map<String, Long> meridiansMap = meridiansList.stream().filter(StringUtils::isNotBlank).collect(Collectors.groupingBy(s -> s,Collectors.counting()));
        long meridiansCount = meridiansList.stream().filter(StringUtils::isNotBlank).count();
        Map<String, String> flavorRes = getStatistics(flavorCount, flavorMap);
        Map<String, String> propertyRes = getStatistics(propertyCount, propertyMap);
        Map<String, String> meridiansRes = getStatistics(meridiansCount, meridiansMap);
        HerbStatisticsRespVo vo = new HerbStatisticsRespVo();
        vo.setFlavorStatistics(flavorRes);
        vo.setPropertyStatistics(propertyRes);
        vo.setMeridiansStatistics(meridiansRes);
        return new ResultModel<HerbStatisticsRespVo>().success(vo);
    }

    @Override
    public ResultModel<PxIngrStatisticsRespVo> getIngredientStatistics(String content, String herbId) {
        QueryWrapper<EtcmIngrPo> wrapper=new QueryWrapper<>();
        if(com.newviews.tcmip.common.utils.StringUtils.isNotBlank(content)){
            wrapper.and(w->w.like( "t2.ingr_zh_name", content)
                    .or().like( "t2.ingr_zh_name_py", content)
                    .or().like( "t2.ingr_zh_name_wb", content)
                    .or().like( "t2.ingr_zh_name_abb", content)
                    .or().like( "t2.ingr_en_name", content)
                    .or().like( "t2.ingr_en_name_abb", content)
                    .or().like( "t2.ingr_latin_name", content)
                    .or().like( "t2.ingr_latin_name_abb", content)
                    .or().like( "t2.ingr_name_alias", content)
            );
        }
        wrapper.eq("t1.herb_id", herbId);

        List<EtcmIngrPo> ingrList = etcmPxExMapper.getIngrList(wrapper);
        Map<String, List<EtcmIngrPo>> ingrBbbMap = ingrList.stream().collect(Collectors.groupingBy(EtcmIngrPo::getIngrBbbCode));
        Map<String, List<EtcmIngrPo>> ingrCaco2Map = ingrList.stream().collect(Collectors.groupingBy(EtcmIngrPo::getIngrCaco2Code));
        Map<String, List<EtcmIngrPo>> ingrHiaMap = ingrList.stream().collect(Collectors.groupingBy(EtcmIngrPo::getIngrHiaCode));
        Map<String, List<EtcmIngrPo>> ingrHobMap = ingrList.stream().collect(Collectors.groupingBy(EtcmIngrPo::getIngrHobCode));
        List<String> ingrBbbList = getIngrStatistics(ingrList.size(), ingrBbbMap);
        List<String> ingrCaco2List = getIngrStatistics(ingrList.size(), ingrCaco2Map);
        List<String> ingrHiaList = getIngrStatistics(ingrList.size(), ingrHiaMap);
        List<String> ingrHobList = getIngrStatistics(ingrList.size(), ingrHobMap);
        PxIngrStatisticsRespVo vo = new PxIngrStatisticsRespVo();
        vo.setIngrBbb(ingrBbbList);
        vo.setIngrCaco2(ingrCaco2List);
        vo.setIngrHia(ingrHiaList);
        vo.setIngrHob(ingrHobList);
        return new ResultModel<PxIngrStatisticsRespVo>().success(vo);
    }



    @Override
    public ResultModel<NetworkStatisticsRespVo> networkStatistics(String herbId, String langCode, String uiTypeCode) {
        List<EtcmIngrIngrPo> ingrAndIngrList = etcmHerbExMapper.getIngrAndIngrByPxId(herbId, langCode);

        List<String> mylist=new ArrayList<>();
        List<EtcmIngrIngrPo> ingrAndIngrList_new= new ArrayList<>();
        for(EtcmIngrIngrPo it:ingrAndIngrList){
            if (!mylist.contains(it.getIngrCode()+it.getTargetIngrCode()) && !mylist.contains(it.getTargetIngrCode()+it.getIngrCode()) && !it.getIngrCode().equals(it.getTargetIngrCode())) {
                mylist.add(it.getIngrCode()+it.getTargetIngrCode());
                ingrAndIngrList_new.add(it);
            }
        }

        List<HerbIngrVo> herbAndIngrList = etcmHerbExMapper.getHerbAndIngrByPxId(herbId, langCode);
        //List<EtcmUiElPo> uiElNameList = etcmPxExMapper.getUIElName(uiTypeCode, langCode);

        PxNetworkStatisticsRespVo res = etcmPxServiceInf.getPxNetworkStatisticsRespVoResultModel(langCode, null, null, null, null, null, ingrAndIngrList_new, herbAndIngrList);
        NetworkStatisticsRespVo vo = new NetworkStatisticsRespVo();
        vo.setScatterDiagram(res.getScatterDiagram());
        return new ResultModel<NetworkStatisticsRespVo>().success(vo);

    }

    @Override
    public ResultModel<PageModel<Map<String, String>>> networkPage(String herbId, String langCode, String uiTypeCode, Integer pageNo, Integer pageSize) {
        List<EtcmIngrIngrPo> ingrAndIngrList = etcmHerbExMapper.getIngrAndIngrByPxId(herbId, langCode);
        List<String> mylist=new ArrayList<>();
        List<EtcmIngrIngrPo> ingrAndIngrList_new= new ArrayList<>();
        for(EtcmIngrIngrPo it:ingrAndIngrList){
            if (!mylist.contains(it.getIngrCode()+it.getTargetIngrCode()) && !mylist.contains(it.getTargetIngrCode()+it.getIngrCode()) && !it.getIngrCode().equals(it.getTargetIngrCode())) {
                mylist.add(it.getIngrCode()+it.getTargetIngrCode());
                ingrAndIngrList_new.add(it);
            }
        }
        List<HerbIngrVo> herbAndIngrList = etcmHerbExMapper.getHerbAndIngrByPxId(herbId, langCode);
        List<EtcmUiElPo> uiElNameList = etcmPxExMapper.getUIElName(uiTypeCode, langCode);
        PageModel<Map<String, String>> page = etcmPxServiceInf.getNetworkTablePage(langCode, null, null, null, null, null, ingrAndIngrList_new, herbAndIngrList, uiElNameList, pageNo, pageSize);
        return new ResultModel<PageModel<Map<String, String>>>().success(page);
    }

    private List<String> getIngrStatistics(int totalNumber, Map<String, List<EtcmIngrPo>> map) {
        List<String> arr = new ArrayList<>();
        for (String key : map.keySet()) {
            List<EtcmIngrPo> list = map.get(key);
            BigDecimal totalSize = new BigDecimal(totalNumber);
            BigDecimal size = new BigDecimal(list.size());
            BigDecimal bigDecimal = size.divide(totalSize,2, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
            arr.add(bigDecimal.toString());
        }
        return arr;
    }

    private Map<String, String> getStatistics(long totalNumber,Map<String, Long> map){
        Map<String,String> mapRes = new HashMap<>(16);
        map.keySet().forEach(s -> {
            BigDecimal totalCount = new BigDecimal(totalNumber);
            BigDecimal size = new BigDecimal(map.get(s));
            BigDecimal bigDecimal = size.divide(totalCount,2, RoundingMode.HALF_UP).multiply(new BigDecimal(100));
            mapRes.put(s,bigDecimal.toString());
        });
        return mapRes;
    }

    @Override
    public ResultModel<List<EtcmHerbFlavorPo>> getFlavorList(String languageCode) {
        List<EtcmHerbFlavorPo> clsList = etcmHerbFlavorServiceInf.list(new QueryWrapper<EtcmHerbFlavorPo>().eq("status", CommonConsts.COMMON_YES).eq( "language_code", languageCode));
        return new ResultModel<List<EtcmHerbFlavorPo>>().success(clsList);
    }

    @Override
    public ResultModel<List<EtcmHerbPropertyPo>> getPropertyList(String languageCode) {
        List<EtcmHerbPropertyPo> clsList = etcmHerbPropertyServiceInf.list(new QueryWrapper<EtcmHerbPropertyPo>().eq("status", CommonConsts.COMMON_YES).eq( "language_code", languageCode));
        return new ResultModel<List<EtcmHerbPropertyPo>>().success(clsList);
    }




    @Override
    public ResultModel<List<EtcmCommonBaseInfoRespVO>> getDetails(String herbId, String languageCode, String uiTypeCode) {
        List<EtcmHerbExPo> exList = etcmHerbExMapper.getList(new QueryWrapper<EtcmHerbExPo>()
                .eq("t1.status", CommonConsts.COMMON_YES)
                .eq("t2.status", CommonConsts.COMMON_YES)
                .eq("t1.herb_id", herbId)
                .eq("t2.language_code", languageCode)
                .eq("t2.ui_type_code", uiTypeCode)
                .isNotNull("t1.herb_ex_con")
                .orderByAsc("t2.ui_el_sort")
        );
        List<EtcmCommonBaseInfoRespVO> resList = new ArrayList<>();
        for(EtcmHerbExPo etcmHerbExPo:exList){
            EtcmCommonBaseInfoRespVO respVO = new EtcmCommonBaseInfoRespVO();
            respVO.setUiElName(etcmHerbExPo.getUiElName());
            respVO.setUiElValue(etcmHerbExPo.getHerbExCon());
            resList.add(respVO);
        }
        return new ResultModel<List<EtcmCommonBaseInfoRespVO>>().success(resList);
    }

    @Override
    public ResultModel<PageModel<Map<String, String>>> getPageByIngr(String languageCode, String uiTypeCode, String herbId, Integer pageNo, Integer pageSize, String searchName, String ingrBbb, String ingrCaco2, String ingrHia,String ingrHob,String sortType) {
        uiTypeCode = CommonConsts.UI_TYPE_CODE_INGR;
        QueryWrapper<EtcmIngrPo> wrapper = new QueryWrapper<>();
        wrapper.eq("t1.herb_id",herbId);
        wrapper.eq("t1.status",CommonConsts.COMMON_YES);
        wrapper.eq("t2.status",CommonConsts.COMMON_YES);


        if (StringUtils.isNotBlank(ingrBbb)){
            wrapper.in("t2.ingr_bbb_code",ingrBbb.split(","));
        }
        if (StringUtils.isNotBlank(ingrCaco2)){
            wrapper.in("t2.ingr_caco2_code",ingrCaco2.split(","));
        }
        if (StringUtils.isNotBlank(ingrHia)){
            wrapper.in("t2.ingr_hia_code",ingrHia.split(","));
        }
        if (StringUtils.isNotBlank(ingrHob)){
            wrapper.in("t2.ingr_hob_code",ingrHob.split(","));
        }
        if (StringUtils.isNotBlank(searchName)){
            wrapper.and(w->w.like( "t2.ingr_zh_name", searchName)
                    .or().like( "t2.ingr_zh_name_py", searchName)
                    .or().like( "t2.ingr_zh_name_wb", searchName)
                    .or().like( "t2.ingr_zh_name_abb", searchName)
                    .or().like( "t2.ingr_en_name", searchName)
                    .or().like( "t2.ingr_en_name_abb", searchName)
                    .or().like( "t2.ingr_latin_name", searchName)
                    .or().like( "t2.ingr_latin_name_abb", searchName)
                    .or().like( "t2.ingr_name_alias", searchName)
            );
        }

        if (StringUtils.isNotBlank(sortType)){
            if(sortType.toLowerCase().equals(CommonConsts.SORT_TYPE_ASC.toLowerCase())){
                wrapper.orderByAsc("t2.ingr_code");
            }else {
                wrapper.orderByDesc("t2.ingr_code");
            }
        }else{
            wrapper.orderByAsc("t2.ingr_code");
        }


        IPage<EtcmIngrPo> page = etcmHerbExMapper.getPageByIngr(new Page<>(pageNo, pageSize),wrapper);

        List<Map<String,String>> resList = new ArrayList<>();
        for (EtcmIngrPo record : page.getRecords()) {
            HashMap<String,String> map = new HashMap<>();
            List<EtcmIngrExPo> exList = etcmIngrExServiceInf.list(new QueryWrapper<EtcmIngrExPo>()
                    .eq(EtcmIngrExPo.STATUS, CommonConsts.COMMON_YES)
                    .eq(EtcmIngrExPo.INGR_ID, record.getIngrCode())
                    .eq("language_code",languageCode)
                    .eq("ui_type_code",uiTypeCode)
            );

            if(CommonConsts.LANG_CODE_ENG.toLowerCase().equals(languageCode.toLowerCase())) {
                map.put(UiElCodeEnums.HERB_NAME.getUiElCode(), record.getHerbEnName());
            }
            if(CommonConsts.LANG_CODE_CHN.toLowerCase().equals(languageCode.toLowerCase())) {
                map.put(UiElCodeEnums.HERB_NAME.getUiElCode(), record.getHerbZhName());
            }
            for (EtcmIngrExPo etcmIngrExPo : exList) {
                map.put(etcmIngrExPo.getUiElCode(),etcmIngrExPo.getIngrExCon());
            }
            resList.add(map);
        }
        PageModel<Map<String,String>> resPage = new PageModel<>();
        resPage.setPageNo(pageNo);
        resPage.setPageSize(pageSize);
        resPage.setRecords(resList);
        resPage.setTotalCount(page.getTotal());
        return new ResultModel<PageModel<Map<String,String>>>().success(resPage);
    }



    @Override
    public ResultModel<PageModel<Map<String, String>>> getPageByExperimentalRecords(String languageCode, String uiTypeCode, String herbId, Integer pageNo, Integer pageSize, String searchName,String sortType) {
        QueryWrapper<EtcmExperimentalRecordsPo> wrapper=new QueryWrapper<>();
        if(com.newviews.tcmip.common.utils.StringUtils.isNotBlank(searchName)){
            wrapper.and(w->w.like("t3.er_zh_name", searchName)
                    .or().like("t3.er_zh_name_py", searchName)
                    .or().like("t3.er_zh_name_wb", searchName)
                    .or().like("t3.er_zh_name_abb", searchName)
                    .or().like("t3.er_en_name", searchName)
                    .or().like("t3.er_en_name_abb", searchName)
                    .or().like("t3.er_latin_name", searchName)
                    .or().like("t3.er_latin_name_abb", searchName)
                    .or().like("t3.er_name_alias", searchName));
        }
        if(sortType.equalsIgnoreCase(CommonConsts.SORT_TYPE_ASC)){
            wrapper.orderByAsc("t2.er_id");
        }else {
            wrapper.orderByDesc("t2.er_id");
        }
        IPage<EtcmExperimentalRecordsIngrPo> pageEr = etcmHerbExMapper.getHerbByExperimentalRecords(new Page(pageNo, pageSize), wrapper, herbId);
        List<Map<String,String>> resultList=new ArrayList<>();

        List<EtcmUiElPo> uiElName = etcmPxExMapper.getUIElName(uiTypeCode, languageCode);
        for (EtcmExperimentalRecordsIngrPo record : pageEr.getRecords()) {
            Map<String, String> map = getStringStringMap(languageCode, record, uiElName);
            resultList.add(map);
        }

        PageModel<Map<String,String>> page=new PageModel<>();
        page.setPageNo(pageNo);
        page.setPageSize(pageSize);
        page.setRecords(resultList);
        page.setTotalCount(pageEr.getTotal());
        return new ResultModel<PageModel<Map<String,String>>>().success(page);
    }

    @Override
    public ResultModel<PageModel<Map<String, String>>> getPageByPx(String languageCode, String uiTypeCode, String herbId, Integer pageNo, Integer pageSize, String searchName,String sortType) {
        QueryWrapper<EtcmPxPo> wrapper = new QueryWrapper<>();
        wrapper.eq("t1.herb_id",herbId);
        wrapper.eq("t1.status",CommonConsts.COMMON_YES);
        wrapper.eq("t2.status",CommonConsts.COMMON_YES);
        if (StringUtils.isNotBlank(searchName)){
            wrapper.and(w->w.like("t2.px_zh_name", searchName)
                    .or().like("t2.px_zh_name_py", searchName)
                    .or().like("t2.px_zh_name_wb", searchName)
                    .or().like("t2.px_zh_name_abb", searchName)
                    .or().like("t2.px_en_name", searchName)
                    .or().like("t2.px_en_name_abb", searchName)
                    .or().like("t2.px_latin_name", searchName)
                    .or().like("t2.px_latin_name_abb", searchName));
        }
        if(sortType.toLowerCase().equals(CommonConsts.SORT_TYPE_ASC.toLowerCase())){
            wrapper.orderByAsc("t2.px_code");
        }else {
            wrapper.orderByDesc("t2.px_code");
        }
        IPage<EtcmPxPo> page = etcmHerbExMapper.getPageByPx(new Page<>(pageNo, pageSize),wrapper);

        List<Map<String,String>> resList = new ArrayList<>();
        for (EtcmPxPo record : page.getRecords()) {
            HashMap<String,String> map = new HashMap<>();
            List<EtcmPxExPo> exList = etcmPxExServiceInf.list(new QueryWrapper<EtcmPxExPo>()
                    .eq(EtcmPxExPo.STATUS, CommonConsts.COMMON_YES)
                    .eq(EtcmPxExPo.PX_ID, record.getPxCode())
                    .eq("language_code",languageCode)
                    .eq("ui_type_code",uiTypeCode)
            );
            for (EtcmPxExPo etcmPxExPo : exList) {
                map.put(etcmPxExPo.getUiElCode(),etcmPxExPo.getPxExCon());
            }
            resList.add(map);
        }
        PageModel<Map<String,String>> resPage = new PageModel<>();
        resPage.setPageNo(pageNo);
        resPage.setPageSize(pageSize);
        resPage.setRecords(resList);
        resPage.setTotalCount(page.getTotal());
        return new ResultModel<PageModel<Map<String,String>>>().success(resPage);
    }

    @Override
    public ResultModel<PageModel<Map<String, String>>> getPageByCombinedHerbs(String languageCode, String uiTypeCode, String herbId, Integer pageNo, Integer pageSize, String searchName,String sortType) {
        QueryWrapper<EtcmHerbHerbPo> wrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(searchName)){
//            if (CommonConsts.LANG_CODE_ENG.equals(languageCode)){
//                wrapper.like("t3.herb_en_name",searchName);
//            }
//
//            if (CommonConsts.LANG_CODE_CHN.equals(languageCode)){
//                wrapper.like("t3.herb_zh_name",searchName);
//            }
            wrapper.and(w->w.like( "t3.herb_zh_name", searchName)
                    .or().like( "t3.herb_zh_name_py", searchName)
                    .or().like( "t3.herb_zh_name_wb", searchName)
                    .or().like( "t3.herb_zh_name_abb", searchName)
                    .or().like( "t3.herb_en_name", searchName)
                    .or().like( "t3.herb_en_name_abb", searchName)
                    .or().like( "t3.herb_latin_name", searchName)
                    .or().like( "t3.herb_latin_name_abb", searchName)
                    .or().like( "t3.herb_name_alias", searchName));

        }

        wrapper.eq("t1.herb_code",herbId);

//        if(sortType.toLowerCase().equals(CommonConsts.SORT_TYPE_ASC.toLowerCase())){
//            wrapper.orderByAsc("t1.herb_herb_distance");
//        }else {
//            wrapper.orderByDesc("t1.herb_herb_distance");
//        }
//        wrapper.orderByAsc("t1.herb_herb_distance");
        wrapper.last("limit 200");

        List<EtcmHerbHerbPo> page = etcmHerbExMapper.getPageByCombinedHerbs(wrapper);


        List<EtcmUiElPo> uiElNameList = etcmPxExMapper.getUIElName(uiTypeCode, languageCode);

        List<Map<String,String>> resMap = new ArrayList<>();


        if(sortType.toLowerCase().equals(CommonConsts.SORT_TYPE_ASC.toLowerCase())){
            page = page.stream().sorted(Comparator.comparing(EtcmHerbHerbPo::getHerbHerbDistance)).collect(Collectors.toList());
        }else {
            page = page.stream().sorted(Comparator.comparing(EtcmHerbHerbPo::getHerbHerbDistance).reversed()).collect(Collectors.toList());
        }
        List<EtcmHerbHerbPo> collect = page.stream().skip((pageNo - 1) * pageSize).limit(pageSize).
                collect(Collectors.toList());


        collect.forEach(etcmHerbHerbPo -> {
            Map<String, String> stringStringMap = getStringStringMap(languageCode, etcmHerbHerbPo, uiElNameList);
            resMap.add(stringStringMap);
        });

        try{
            PrintStream ps = new PrintStream("D:\\1.txt");
            //可能会出现异常，直接throws就行了
            System.setOut(ps);
            //把创建的打印输出流赋给系统。即系统下次向 ps输出
            for(Map<String, String> it:resMap){
                System.out.println(it.toString());
            }
            System.out.println("我在D盘下的1.txt文件中去了。");
            ps.close();
        }catch (Exception ex){

        }

        PageModel<Map<String,String>> resPage = new PageModel<>();
        resPage.setPageNo(pageNo);
        resPage.setPageSize(pageSize);
        resPage.setRecords(resMap);
        resPage.setTotalCount(page.size());
        return new ResultModel<PageModel<Map<String,String>>>().success(resPage);
    }



    @Override
    public ResultModel<PageModel<Map<String, String>>> getPageByAssociatedDiseases(String languageCode, String uiTypeCode, String herbId, Integer pageNo, Integer pageSize, String searchName,String sortType) {
        QueryWrapper<EtcmHerbDiseasePo> wrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(searchName)){
//            if (CommonConsts.LANG_CODE_ENG.equals(languageCode)){
//                wrapper.like("t2.herb_en_name",searchName);
//            }
//
//            if (CommonConsts.LANG_CODE_CHN.equals(languageCode)){
//                wrapper.like("t2.herb_zh_name",searchName);
//            }

            wrapper.and(w->w.like( "t3.disease_zh_name", searchName)
                    .or().like( "t3.disease_zh_name_py", searchName)
                    .or().like( "t3.disease_zh_name_wb", searchName)
                    .or().like( "t3.disease_zh_name_abb", searchName)
                    .or().like( "t3.disease_en_name", searchName)
                    .or().like( "t3.disease_en_name_abb", searchName)
                    .or().like( "t3.disease_latin_name", searchName)
                    .or().like( "t3.disease_latin_name_abb", searchName)
                    .or().like( "t3.disease_name_alias", searchName));
        }
        wrapper.eq("t1.herb_id",herbId);
        //wrapper.orderByAsc("t1.herb_disease_distance");
        wrapper.last("limit 200");

        List<EtcmHerbDiseasePo> page = etcmHerbExMapper.getPageByAssociatedDiseases(wrapper);
        List<EtcmUiElPo> uiElNameList = etcmPxExMapper.getUIElName(uiTypeCode, languageCode);

        List<Map<String,String>> resMap = new ArrayList<>();

        if(sortType.toLowerCase().equals(CommonConsts.SORT_TYPE_ASC.toLowerCase())){
            page = page.stream().sorted(Comparator.comparing(EtcmHerbDiseasePo::getHerbDiseaseDistance)).collect(Collectors.toList());
        }else {
            page = page.stream().sorted(Comparator.comparing(EtcmHerbDiseasePo::getHerbDiseaseDistance).reversed()).collect(Collectors.toList());
        }
        List<EtcmHerbDiseasePo> collect = page.stream().skip((pageNo - 1) * pageSize).limit(pageSize).
                collect(Collectors.toList());

        collect.forEach(etcmHerbHerbPo -> {
            Map<String, String> stringStringMap = getStringStringMap(languageCode, etcmHerbHerbPo, uiElNameList);
            resMap.add(stringStringMap);
        });
        PageModel<Map<String,String>> resPage = new PageModel<>();
        resPage.setPageNo(pageNo);
        resPage.setPageSize(pageSize);
        resPage.setRecords(resMap);
        resPage.setTotalCount(page.size());
        return new ResultModel<PageModel<Map<String,String>>>().success(resPage);
    }

    @Override
    public ResultModel<PageModel<Map<String, String>>> getPageByIngrTarget(String languageCode, String uiTypeCode, String herbId, Integer pageNo, Integer pageSize, String searchName,String type,String sortType) {
        if (StringUtils.isBlank(type)){
            return new ResultModel<PageModel<Map<String, String>>>().success();
        }
        QueryWrapper<EtcmTargetPo> wrapper=new QueryWrapper<>();
        wrapper.eq("t5.language_code", languageCode);
        if(com.newviews.tcmip.common.utils.StringUtils.isNotBlank(type)){
            String[] targetArray = type.split(CommonConsts.SPIT);
            wrapper.in("t3.target_type_code", targetArray);
        }
        if(com.newviews.tcmip.common.utils.StringUtils.isNotBlank(searchName)){
            wrapper.and(w->w.like("t3.target_zh_name", searchName)
                    .or().like("t3.target_zh_name_py", searchName)
                    .or().like("t3.target_zh_name_wb", searchName)
                    .or().like("t3.target_zh_name_abb", searchName)
                    .or().like("t3.target_en_name", searchName)
                    .or().like("t3.target_en_name_abb", searchName)
                    .or().like("t3.target_latin_name", searchName)
                    .or().like("t3.target_latin_name_abb", searchName)
                    .or().like("t3.target_name_alias", searchName));
        }
        if(sortType.equalsIgnoreCase(CommonConsts.SORT_TYPE_ASC)){
            wrapper.orderByAsc("t2.target_id");
        }else {
            wrapper.orderByDesc("t2.target_id");
        }
        //wrapper.isNotNull("t3.id");
        IPage<EtcmIngrTargetPo> pageTarget = etcmHerbExMapper.getTarget(new Page(pageNo, pageSize), wrapper,herbId);
        List<Map<String,String>> resultList=new ArrayList<>();

        List<EtcmUiElPo> uiElName = etcmPxExMapper.getUIElName(uiTypeCode, languageCode);
        pageTarget.getRecords().forEach(etcmIngrTargetPo -> {
            Map<String, String> map = getStringStringMap(languageCode, etcmIngrTargetPo, uiElName);
            resultList.add(map);
        });
        PageModel<Map<String,String>> page=new PageModel<>();
        page.setPageNo(pageNo);
        page.setPageSize(pageSize);
        page.setRecords(resultList);
        page.setTotalCount(pageTarget.getTotal());
        return new ResultModel<PageModel<Map<String,String>>>().success(page);
    }

    @Override
    public ResultModel<Map<String, String>> getTargetStatistics(String content, String herbId) {
        QueryWrapper<EtcmTargetPo> wrapper=new QueryWrapper<>();
       // wrapper.eq("t1.herb_id", herbId);
        if(com.newviews.tcmip.common.utils.StringUtils.isNotBlank(content)){
            wrapper.and(w->w.like("t3.target_zh_name", content)
                    .or().like("t3.target_zh_name_py", content)
                    .or().like("t3.target_zh_name_wb", content)
                    .or().like("t3.target_zh_name_abb", content)
                    .or().like("t3.target_en_name", content)
                    .or().like("t3.target_en_name_abb", content)
                    .or().like("t3.target_latin_name", content)
                    .or().like("t3.target_latin_name_abb", content)
                    .or().like("t3.target_name_alias", content));
        }

        //wrapper.isNotNull("t3.id");
        List<EtcmTargetPo> list = etcmHerbExMapper.getTargetList( wrapper,herbId);
        Map<String, Long> map = list.stream().map(EtcmTargetPo::getTargetTypeCode).filter(Objects::nonNull).collect(Collectors.groupingBy(s -> s,Collectors.counting()));
        Map<String, String> res = getStatistics(list.size(), map);
        return new ResultModel<Map<String, String>>().success(res);
    }

    private static Map<String, String> getStringStringMap(String langCode, EtcmExperimentalRecordsIngrPo recordsIngrPo, List<EtcmUiElPo> uiElNameList) {
        Map<String,String> map = new HashMap<>(16);
        for (EtcmUiElPo etcmUiElPo : uiElNameList) {
            switch (etcmUiElPo.getUiElSort()){
                case 1:
                    map.put(etcmUiElPo.getUiElCode(), recordsIngrPo.getErId());
                    break;
                case 2:
                    if (CommonConsts.LANG_CODE_ENG.equals(langCode)){
                        map.put(etcmUiElPo.getUiElCode(), recordsIngrPo.getErEnName());
                    }
                    if (CommonConsts.LANG_CODE_CHN.equals(langCode)){
                        map.put(etcmUiElPo.getUiElCode(), recordsIngrPo.getErZhName());
                    }
                    break;
                case 3:
                    map.put(etcmUiElPo.getUiElCode(), recordsIngrPo.getPubchemCid());
                    break;
                case 5:
                    map.put(etcmUiElPo.getUiElCode(), recordsIngrPo.getMolecularFormula());
                    break;
                case 6:
                    map.put(etcmUiElPo.getUiElCode(), recordsIngrPo.getMolecularWeight());
                    break;
                case 7:
                    map.put(etcmUiElPo.getUiElCode(), recordsIngrPo.getConcentration());
                    break;
                case 8:
                    map.put(etcmUiElPo.getUiElCode(),recordsIngrPo.getCelllines());
                    break;
                case 9:
                    map.put(etcmUiElPo.getUiElCode(),recordsIngrPo.getOrangism());
                default:
                    map.put(UiElCodeEnums.IS_MAP.getUiElCode(),recordsIngrPo.getIsMap());

            }

        }
        return map;
    }
    private static Map<String, String> getStringStringMap(String langCode, EtcmIngrTargetPo etcmIngrTargetPo, List<EtcmUiElPo> uiElNameList) {
        Map<String,String> map = new HashMap<>(16);
        for (EtcmUiElPo etcmUiElPo : uiElNameList) {
            switch (etcmUiElPo.getUiElSort()){
                case 1:
                    map.put(etcmUiElPo.getUiElCode(), etcmIngrTargetPo.getTargetId());
                    break;
                case 2:
                    map.put(etcmUiElPo.getUiElCode(), etcmIngrTargetPo.getSymbolIdHum());
                    break;
                case 3:
                    if (CommonConsts.LANG_CODE_ENG.equals(langCode)){
                        map.put(etcmUiElPo.getUiElCode(), etcmIngrTargetPo.getIngrEnName() +"||"+ etcmIngrTargetPo.getIngrId());
                    }
                    if (CommonConsts.LANG_CODE_CHN.equals(langCode)){
                        map.put(etcmUiElPo.getUiElCode(), etcmIngrTargetPo.getIngrZhName()+"||"+ etcmIngrTargetPo.getIngrId());
                    }
                    break;
                case 4:
                    map.put(etcmUiElPo.getUiElCode(), etcmIngrTargetPo.getTypeName());
                    break;
                case 6:
                    map.put(etcmUiElPo.getUiElCode(), etcmIngrTargetPo.getEntrezIdHum());
                    break;
                case 7:
                    map.put(etcmUiElPo.getUiElCode(),etcmIngrTargetPo.getUniprotIdHum());
                default:
            }

        }
        return map;
    }
    private static Map<String, String> getStringStringMap(String langCode, EtcmHerbHerbPo etcmHerbHerbPo, List<EtcmUiElPo> uiElNameList) {
        Map<String,String> map = new HashMap<>(16);
        for (EtcmUiElPo etcmUiElPo : uiElNameList) {
            switch (etcmUiElPo.getUiElSort()){
                case 1:
                    map.put(etcmUiElPo.getUiElCode(), etcmHerbHerbPo.getHerbCode() + "-" + etcmHerbHerbPo.getTargetHerbCode());
                    break;
                case 2:
                    if (CommonConsts.LANG_CODE_ENG.equals(langCode)){
                        map.put(etcmUiElPo.getUiElCode(), etcmHerbHerbPo.getHerbEnName());
                    }
                    if (CommonConsts.LANG_CODE_CHN.equals(langCode)){
                        map.put(etcmUiElPo.getUiElCode(), etcmHerbHerbPo.getHerbZhName());
                    }
                    break;

                case 3:
                    if (CommonConsts.LANG_CODE_ENG.equals(langCode)){
                        map.put(etcmUiElPo.getUiElCode(), etcmHerbHerbPo.getTargetHerbEnName());
                    }
                    if (CommonConsts.LANG_CODE_CHN.equals(langCode)){
                        map.put(etcmUiElPo.getUiElCode(), etcmHerbHerbPo.getTargetHerbZhName());
                    }
                    break;
                case 4:
                    map.put(etcmUiElPo.getUiElCode(), etcmHerbHerbPo.getHerbHerbDistance());
                    break;
                case 5:
                    map.put(etcmUiElPo.getUiElCode(),"");
                default:
            }

        }
        return map;
    }


    private static Map<String, String> getStringStringMap(String langCode, EtcmHerbDiseasePo etcmHerbDiseasePo, List<EtcmUiElPo> uiElNameList) {
        Map<String,String> map = new HashMap<>(16);
        for (EtcmUiElPo etcmUiElPo : uiElNameList) {
            switch (etcmUiElPo.getUiElSort()){
                case 1:
                    map.put(etcmUiElPo.getUiElCode(), etcmHerbDiseasePo.getHerbId() + "-" + etcmHerbDiseasePo.getDiseaseId());
                    break;
                case 2:
                    if (CommonConsts.LANG_CODE_ENG.equals(langCode)){
                        map.put(etcmUiElPo.getUiElCode(), etcmHerbDiseasePo.getHerbEnName());
                    }
                    if (CommonConsts.LANG_CODE_CHN.equals(langCode)){
                        map.put(etcmUiElPo.getUiElCode(), etcmHerbDiseasePo.getHerbZhName());
                    }
                    break;

                case 3:
                    if (CommonConsts.LANG_CODE_ENG.equals(langCode)){
                        map.put(etcmUiElPo.getUiElCode(), etcmHerbDiseasePo.getDiseaseEnName());
                    }
                    if (CommonConsts.LANG_CODE_CHN.equals(langCode)){
                        map.put(etcmUiElPo.getUiElCode(), etcmHerbDiseasePo.getDiseaseZhName());
                    }
                    break;
                case 4:
                    map.put(etcmUiElPo.getUiElCode(), etcmHerbDiseasePo.getHerbDiseaseDistance());
                    break;
                case 5:
                    map.put(etcmUiElPo.getUiElCode(),etcmHerbDiseasePo.getPValue());
                default:
            }

        }
        return map;
    }



}
